package com.linkoog.devtools.type.impl;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.linkoog.devtools.type.Type;
import com.linkoog.devtools.type.TypeBase;
import lombok.Getter;
import lombok.Setter;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 *  自定义类型
 */
public class ObjectType extends TypeBase implements Cloneable{

    /**
     *  type的声明的原始文本
     */
    @Getter
    protected final String typeDeclaredText;
    /**
     *  type的声明的原始全类名文本
     */
    @Getter
    protected final String typeDeclaredFullText;
    @Getter @Setter
    private Map<String, Type> fieldTypeMap;
    @Getter @Setter
    private Map<String, ObjectFieldDoc> fieldDocMap;



    @JsonCreator
    public ObjectType(@JsonProperty("typeName")String typeName, @JsonProperty("typeFullName")String typeFullName,@JsonProperty("typeDeclaredText") String typeDeclaredText,@JsonProperty("typeDeclaredFullText") String typeDeclaredFullText) {
        super(typeName, typeFullName);
        this.typeDeclaredText = typeDeclaredText;
        this.typeDeclaredFullText = typeDeclaredFullText;
    }

    @Override
    public ObjectType clone()  {
        ObjectType copy = new ObjectType(this.getTypeName(), this.getTypeFullName(), this.typeDeclaredText, this.typeDeclaredFullText);
        copy.fieldTypeMap = new LinkedHashMap<>();
        copy.fieldDocMap = new LinkedHashMap<>();
        return copy;
    }
}
